package com.nn.controller;

import com.nn.pojo.AroundTravel;
import com.nn.service.AroundTravelService;
import com.nn.vo.PageResult;
import com.nn.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//周边旅游业务层
@RestController
@CrossOrigin
@RequestMapping("/aroundTravel")
public class AroundTravelController {
    @Autowired
    private AroundTravelService aroundTravelService;

    /**
     * /aroundTravel/getaroundTravelList
     */
    @GetMapping("/getaroundTravelList")
    public SysResult getaroundTravelList(PageResult pageResult) {
        pageResult = aroundTravelService.getaroundTravelList(pageResult);
        return SysResult.success(pageResult);
    }

    /**
     * delete("/aroundTravel/deletearoundTravelById"
     */
    @DeleteMapping("deletearoundTravelById")
    public SysResult deletearoundTravelById(Integer id) {
        aroundTravelService.deletearoundTravelById(id);
        return SysResult.success();
    }

    /**
     * put("/aroundTravel/updatearoundTravelStatus",
     */
    @PutMapping("/updatearoundTravelStatus")
    public SysResult updateStatus(@RequestBody AroundTravel aroundTravel) {
        aroundTravelService.updateStatus(aroundTravel);
        return SysResult.success();
    }

    /**
     * await this.$http.get("/aroundTravel/"+aroundTravel.id)
     */
    @GetMapping("/{id}")
    public SysResult updatearoundTravelBtn(@PathVariable Integer id) {
        AroundTravel aroundTravel = aroundTravelService.getaroundTravelId(id);
        return SysResult.success(aroundTravel);
    }

    /**
     * await this.$http.put('/aroundTravel/updatearoundTravel',this.updateAdTlform)
     */
    @PutMapping("/updatearoundTravel")
    public SysResult updatearoundTravel(@RequestBody AroundTravel aroundTravel) {
        aroundTravelService.updatearoundTravel(aroundTravel);
        return SysResult.success();
    }


}
